package day07;

import java.util.Scanner;

/*
5个评委评分，去掉最高分最低分，求平均值
 */
public class CalTotalAvg1 {
    public static void main(String[] args) {
        double scores[] = getArray();//录评分
        double avg = getAvg(scores);
        System.out.println("平均值是"+avg);
    }
    //录评分
    public static double [] getArray(){
        Scanner scan = new Scanner(System.in);
        double [] scores = new double[6];
        for(int i = 0;i<scores.length;i++){
            System.out.println("请输入第"+(i+1)+"个评委的分数：");
             scores[i] = scan.nextDouble();
        }
        return scores;
    }
    //求总分
    public static double totalscore(double[] scores){
        double totalScore = 0.0;
        double max = scores[0];
        double min = scores[0];
        for (int i = 0;i<scores.length;i++){
            if(scores[i]>max){
                max = scores[i];
            }
            if(scores[i]<min){
                min = scores[i];
            }
             totalScore += scores[i];
        }
        totalScore = totalScore-max-min;
        return totalScore;
    }
    //求平均值
    public static  double getAvg(double[] scores){
        double avg = totalscore(scores)/(scores.length-2);
        return avg;
    }
}
